package com.hospital.warehouse.drugstock.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.hospital.util.JMyUtil;
import com.hospital.warehouse.drugdicts.entity.Drugdicts;
import com.hospital.warehouse.instock.entity.Instock;
import com.hospital.warehouse.storehouse.entity.Storehouse;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.math.BigDecimal;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author Mr. YR
 * @since 2020-04-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("drugstock")
public class Drugstock extends Model<Drugstock> {

	private static final long serialVersionUID = 1L;

	@TableId(value = "ds_is_id", type = IdType.INPUT)
	private Integer ds_is_id;
	@TableField(exist = false)
	private Instock instock;

	@TableField(exist = false)
	private Drugdicts drug;
	@TableField(exist = false)
	private Storehouse storehouse;

	@TableField("ds_num")
	private Integer ds_num;
	@TableField(exist = false)
	private Integer ds_num_min;
	@TableField(exist = false)
	private Integer ds_num_max;

	@TableField(exist = false)
	private Long ds_passedmonth;
	@TableField(exist = false)
	private Long ds_surplusmonth;
	@TableField(exist = false)
	private Integer ds_month_min;
	@TableField(exist = false)
	private Integer ds_month_max;

	@TableField("flag")
	private Integer flag;

	@Override
	protected Serializable pkVal() {
		return this.ds_is_id;
	}

	public Long getDs_passedmonth() {
		return JMyUtil.monthDifference1(instock.getIs_startdate());
	}

	public Long getDs_surplusmonth() {
		return instock.getIs_effectivetime() - getDs_passedmonth();
	}

}
